<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>

<!DOCTYPE html>
<html>
<head>
    <title><spring:message code="message.lable.drugqualityspecSeeStd"/></title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
    <!--[if lt IE 9]>
        <script src="${ctx}/lib/js/html5shiv.min.js"></script>
        <script src="${ctx}/lib/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
                            
    <section class="content-header">
        <h1>总体采购情况</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first"/></a></li>
                <li><a href="#">统计查询</a></li>
                <li><a href="#">总体采购情况</a></li>
        </ol>
    </section>
        
    <section class="content">
		<div class="box box-success">
    		<div class="box-header with-border">
    			<h3 class="box-title"><fmt:formatDate value='${lastYear}' pattern='yyyy年' />至<fmt:formatDate value='${lastYear2}' pattern='yyyy年' />总体采购情况</h3>
                <div class="box-tools pull-right">
                    <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
                </div><!-- /.box-tools -->
            </div>
            <div class="box-body mchart">
                <div id="mChart" style="height: 300px; width:98%; padding: 8px;"></div>
            </div>
        </div>
        <div class=" box box-success">
            <div class="box-body">
             <form  id="form" method="post" action='${ctx}/anaDruginfo/exportExcelWithAreaYear.html'>
                <div class="input">
                    <div class="textalign">年度<spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                    		<table style="width:100%">
                    			<tr>
                    				<td style="width:50%">
                    					<input id="startYear" name="startYear" class="textinput" type="text" readonly placeholder="开始年度"  data-date-fmt="yyyy"  data-provide="datepicker"/>
                    				</td>
                    				<td>&nbsp;-&nbsp;</td>
                    				<td style="width:50%">
                    					<input id="endYear" name="endYear" class="textinput" type="text" readonly placeholder="结束年度"  data-date-fmt="yyyy"  data-provide="datepicker"/>
                    				</td>
                    			</tr>
                    		</table>
                    </div>
                    
                     <div class="textalign" >
                         <button id="selectSpec" type="button" onclick="search();" class="btn btn-success btn-sm"><spring:message code="message.button.seachSpacing"/></button>
						 <button id="exportExcel" type="button"  class="btn btn-success btn-sm">导 出</button>
                    </div>
                </div>
            </form>
            </div>
          </div>
        <table class="jqgrid" id="gridlist"></table>
        <div id="gridpage"></div>
        <div class="box box-warning bottongroup">
			<button type="button" onclick="window.location.href='${ctx}/anaDruginfo/toAnaByAreaWithSea.html'" class="btn btn-primary btn-sm">季度记录</button>
			<button type="button" onclick="window.location.href='${ctx}/anaDruginfo/toAnaByAreaWithMon.html'" class="btn btn-primary btn-sm">月度记录</button>
		</div>
    </section>
      <%@ include file="/WEB-INF/component/commonJS.jsp"%>
    <script type="text/javascript">
        $(function () {
        	$("#area2").HNSelect({
                url: "${pageContext.request.contextPath}/selectController/getArea.html", data: { ID: '${province}' }, defaultText: "<option value=''><spring:message code="message.select.option"/></option>",
                func: function () {
                    $("#area3").HNSelect({
                        parent_selector: "#area2", url: "${pageContext.request.contextPath}/selectController/getArea.html", dataid: "ID", defaultText: "<option value=''><spring:message code="message.select.option"/></option>",
                    });
                }
            });
        	
        	
            $("#gridlist").jqGrid({
                url: "${ctx}/anaDruginfo/getAnaByAreaWithYear.html",
                mtype: "post",
                datatype: "json",
                autowidth: true,
                height: 310,
                colNames: [
					'操作',
                    '年度',
                    '采购总金额(万)',
                    '西药采购金额(万)', 
                   	'中药采购金额(万)',
                   	'配送金额(万)',
                   	'入库金额(万)',
                    '中药采购率',
                    '配送率',
					'入库率'
                ],
                colModel: [
					{name:'oper',index:'formName', width:80, align:"center", sortable:false,formatter:function(val,option,rowdata){
						var str = "<a href='javascript:void(0)' onclick=\"xgDrug('"+rowdata.date+"')\" style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat -40px -80px' class='opIcon' title='采购药品'></a>";
						str += "<a href='javascript:void(0)' onclick=\"xgHosp('"+rowdata.date+"')\" style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat -20px -120px' class='opIcon' title='采购医院'></a>";
						str += "<a href='javascript:void(0)' onclick=\"xgDel('"+rowdata.date+"')\" style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat -120px -60px' class='opIcon' title='采购配送企业'></a>";
						return str;
					}},
					{ name: 'date', width: 100, align:"center", sortable: false},
                    { name: 'total_amount', width: 80, align:"center", sortable: false},
                    { name: 'western_amount', width: 80, align:"center", sortable: false},
                    { name: 'eastern_amount', width: 80, align:"center", sortable: false},
                    { name: 'del_amount', width: 80, align:"center", sortable: false},
                    { name: 'recp_amount', width: 80, align:"center", sortable: false},
                    { name: 'eastern_ratio', width: 80, align:"center", sortable: false},
                    { name: 'del_ratio', width: 80, align:"center", sortable: false},
                    { name: 'recp_ratio', width: 80, align:"center", sortable: false}
                ],
                rowNum: 20,
                rowList: [10, 20, 50,100],
                rownumbers: true,
                pager: "#gridpage",
                multiselect: false, 
                viewrecords: true,
                caption: "年度统计列表",
                gridComplete:function(){
                    autoRNWidth("gridlist");
                },
                jsonReader: {
                	 repeatitems: false,
                    id: "qualitySpecId"
                },
                loadComplete: function (data) { //完成服务器请求后，回调函数
				if($("#mChart").html().length>0){return;}
                	var option = {
                        	tooltip: {
                            	trigger: 'axis'
                            },
                                toolbox: {
                                    show: true,
                                    feature: {
                                        magicType: { show: true, type: ['line', 'bar'] },
                                        restore: { show: true },
                                        saveAsImage: { show: true }
                                    }
                                },
                                calculable: true,
                                legend: {
                                    data: ['采购总金额', '西药采购金额', '中药采购金额']
                                },
                                xAxis: [
                                    {
                                        type: 'category',
                                        data: eval(data.conditions.yTime)
                                    }
                                ],
                                yAxis: [
                                    {
                                    	type: 'value',
                                        name: '金额(万)',
                                        axisLabel: {
                                            formatter: '{value}'
                                        }
                                    }
                                ],
                                series: [

                                    {
                                        name: '采购总金额',
                                        type: 'bar',
										stack: '总',
                                        data: eval(data.conditions.total)
                                    },
                                    {
                                        name: '西药采购金额',
                                        type: 'bar',
										stack: '金额',
                                        data: eval(data.conditions.western)
                                    },
                                    {
                                        name: '中药采购金额',
                                        type: 'bar',
										stack: '金额',
                                        data: eval(data.conditions.eastern)
                                    }
                                ]
                        };
                    	var myChart = echarts.init(document.getElementById('mChart'), theme);
                        myChart.setOption(option);
                }
            });
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
            $(window).trigger("resize");
			
			$('#exportExcel').bind('click',function(){
            	$('#form').submit();
            });
        });
        function search(page) {
            var area1 = $.trim($("#area1").val());
            var area2 = $.trim($("#area2").val());
            var area3 = $.trim($("#area3").val());
            var startYear = $.trim($("#startYear").val());
            var endYear = $.trim($("#endYear").val());
            
            $("#gridlist").jqGrid('setGridParam',{  
                datatype:'json',
                postData:{
                	"area1":area1,
                	"area2":area2,
                	"area3":area3,
                	"startYear":startYear,
                	"endYear":endYear
                },
                page : (page || 1)
            }).trigger("reloadGrid"); //重新载入  
        }
		
		
		function xgDrug(date) {
			window.location.href="${ctx}/anaDruginfo/toAnaByDrugsWithYear.html?date="+date; 
		}
		
		function xgHosp(date) {
			window.location.href="${ctx}/anaDruginfo/toYearAnaByHosp.html?date="+date; 
		}
		
		function xgDel(date) {
			window.location.href="${ctx}/anaDruginfo/toMonthAnaByComp.html?date="+date; 
		}
    </script>
</body>
</html> 
                          
                  
                  